From 7c60da4eb292c2f210f8de6cda9312f9d119b5b0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 16 May 2016 10:42:29 -0700 Subject: [PATCH] Touch up the error message and warnings --- src/cargo/ops/cargo_rustc/context.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 3660b628e..62f9e9818 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -315,21 +315,22 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let mut ret = Vec::new(); match *unit.target.kind() { - TargetKind::Example | TargetKind::Bin | TargetKind::CustomBuild | - TargetKind::Bench | TargetKind::Test => { + TargetKind::Example | + TargetKind::Bin | + TargetKind::CustomBuild | + TargetKind::Bench | + TargetKind::Test => { ret.push(format!("{}{}", stem, suffix)); } TargetKind::Lib(..) if unit.profile.test => { ret.push(format!("{}{}", stem, suffix)); } TargetKind::Lib(ref libs) => { - for lib in libs.iter() { + for lib in libs { match *lib { LibKind::Dylib => { - match self.dylib(unit.kind) { - Ok((prefix, suffix)) => - ret.push(format!("{}{}{}", prefix, stem, suffix)), - Err(e) => try!(self.config.shell().warn(format!("{}", e))) + if let Ok((prefix, suffix)) = self.dylib(unit.kind) { + ret.push(format!("{}{}{}", prefix, stem, suffix)); } } LibKind::Lib | @@ -341,11 +342,18 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } } + if ret.is_empty() { + if libs.contains(&LibKind::Dylib) { + bail!("cannot produce dylib for `{}` as the target `{}` \ + does not support dynamic libraries", + unit.pkg, self.target_triple) + } + bail!("cannot compile `{}` as the target `{}` does not \ + support any of the output crate types", + unit.pkg, self.target_triple); + } } } - if ret.is_empty() { - bail!("no valid targets found") - } Ok(ret) } -- 2.30.2